/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package cn.gzjp.modules.logis.entity;

import cn.gzjp.common.persistence.BaseEntity;
import cn.gzjp.common.persistence.DataEntity;
import org.hibernate.validator.constraints.Length;
import com.fasterxml.jackson.annotation.JsonBackReference;

import cn.gzjp.common.persistence.TreeEntity;

/**
 * 树形地址Entity
 * @author zengcp
 * @version 2018-05-30
 */
public class AreaType extends DataEntity<AreaType> {
	
	private static final long serialVersionUID = 1L;
	private String name;		// 名称
	private AreaType parent;		// 上级id
	private int sort;		// 排序
	private String parentIds;		// parent_ids

	public AreaType() {
		super();
	}

	public AreaType(String id){
		super(id);
	}

	@Length(min=0, max=64, message="名称长度必须介于 0 和 64 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@JsonBackReference
	public AreaType getParent() {
		return parent;
	}

	public void setParent(AreaType parent) {
		this.parent = parent;
	}

	@Length(min=0, max=11, message="排序长度必须介于 0 和 11 之间")
	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	@Length(min=0, max=512, message="parent_ids长度必须介于 0 和 512 之间")
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}

	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
}